package utils;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * ClassName: Test01
 * Package: utils
 * Description:
 * User: fzykd
 *
 * @Author: LQH
 * Date: 2023-08-15
 * Time: 22:01
 */

//Arrays 数组工具类
public class Test01 {
    public static void main(String[] args) {

        int[] arr = {1,2,3,4,5,6,7};
        int[] arr1 = {1,2,3,4,5,6,7};

        //比较两个数组的引用
        System.out.println(arr1 == arr); //false

        //1.比较两个数组的类容是否相同
        System.out.println(Arrays.equals(arr,arr1));

        //2.toString 返回字符转
        System.out.println(Arrays.toString(arr));

        //3.将指定值填充到数组中 数组元素全部改为10
        Arrays.fill(arr,10);
        System.out.println(Arrays.toString(arr));

        //4.排序 快速排序
        Arrays.sort(arr);
        System.out.println(Arrays.toString(arr));

        //5.查找 前提是数据有序的 找到返回索引 没有就负数
        System.out.println(Arrays.binarySearch(arr, 10));


    }
}
